package com.jshx.sz.gdjt.thread;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.json.JSONArray;
import org.json.JSONObject;

import com.jshx.sz.gdjt.util.AccessDBImp;
import com.jshx.sz.gdjt.util.TDESEncodeUtils;
import com.jshx.sz.gdjt.constant.ApplicationGlobal;

import android.content.pm.PackageInfo;
import android.os.Handler;
import android.os.Message;
 

public class LoginThread  extends Thread{
	private Handler handler;
	private String userName;
	private String password;
	private String responseMsg;
	private HashMap  returnMap = new HashMap ();
	
	public LoginThread()
	{
		
	}
	
	public LoginThread(Handler handler, String userName, String password, HashMap  returnMap)
	{
		this.handler=handler;
		this.userName=userName;
		this.password=password;
		this.returnMap=returnMap;
	}
	public void run() 
	{
		try {
			AccessDBImp dao= new AccessDBImp();
			String re=dao.proDB("login", ",'loginName':'"+this.userName+"','password':'"+this.password+"'");
			HashMap map=new HashMap();
			map=dao.splitDataHashMap(re);
			dao.dataCopyHashMapToHashMap(map, returnMap);
			Message msg=new Message();
			msg.what=ApplicationGlobal.loginsucc;
			handler.sendMessage(msg) ;
		} catch (Exception e) {
			System.out.println(e);
			e.printStackTrace();
			Message msg=new Message();
			msg.what=ApplicationGlobal.loginfail;
			handler.sendMessage(msg) ;
		}  
	}
	
}
